import axios from './axios';
import qs from 'qs';

export function getWarehouseList() {
    return axios.get('/warehouse/manage/show_warehouse_list.do').then(res => Promise.resolve(res.data))
}

export function addWarehouse({
                                 warehouseName,
                                 warehouseAddress,
                                 longitude,
                                 latitude

                             }) {
    const data = qs.stringify({warehouseName, warehouseAddress, longitude, latitude});
    return axios.post('/warehouse/manage/save_warehouse.do', data).then(res => Promise.resolve(res.data))
}

export function modWarehouse({
                                 warehouseName,
                                 warehouseAddress,
                                 longitude,
                                 latitude,
                                 id

                             }) {
    const data = qs.stringify({warehouseName, warehouseAddress, longitude, latitude, id});
    return axios.post('/warehouse/manage/update_warehouse.do', data).then(res => Promise.resolve(res.data))
}

export function getWarehouseSparepart() {
    return axios.get('/spare_parts/manage/select_stock_by_warehouse.do').then(res => Promise.resolve(res.data))
}